package com.mcxx.modules.miniSalvation.order.service.read;

import com.mcxx.modules.base.utils.QueryParamUtil;
import com.mcxx.modules.filemanage.easypoi.util.ExportExcelService;
import com.mcxx.modules.filemanage.file.service.FileService;
import com.mcxx.modules.miniSalvation.order.dao.read.RecheckBatchReadDao;
import com.mcxx.modules.miniSalvation.order.dto.RecheckBatchDTO;
import com.mcxx.modules.miniSalvation.order.dto.RecheckBatchExcelDTO;
import com.mcxx.modules.miniSalvation.order.entity.RecheckBatchEntity;
import com.mcxx.modules.miniSalvation.order.param.RecheckBatchParam;
import com.mcxx.modules.system.entity.TaskExportEntity;
import com.mcxx.modules.system.service.write.TaskExportWriteService;
import com.mcxx.util.Constant;
import com.mcxx.util.DateUtil;
import com.yinhai.ta404.component.audit.vo.ExcelInfo;
import com.yinhai.ta404.core.restservice.requestbean.PageParam;
import com.yinhai.ta404.core.restservice.resultbean.Page;
import com.yinhai.ta404.core.security.vo.UserAccountVo;
import com.yinhai.ta404.core.service.BaseService;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Date;
import java.util.List;

@Slf4j
@Service("recheckBatchReadService")
@TaTransactional(readOnly = true)
public class RecheckBatchReadService extends BaseService {

    @Autowired
    private  RecheckBatchReadDao recheckBatchReadDao;


    public Page listBatchRecheck(RecheckBatchParam param, PageParam pageParam, UserAccountVo accountVo){

        QueryParamUtil.setBaseParamValue(param,accountVo);


        recheckBatchReadDao.beginPager(pageParam);

        String nowMonth = DateUtil.sdf2.format(new Date());
        String nowYear = nowMonth.substring(0,4)+"-01-01";
        nowMonth = nowMonth.substring(0,nowMonth.length()-2)+"01";
        param.setNowMonth(nowMonth);
        param.setNowYear(nowYear);
        List<RecheckBatchDTO>  recheckBatchList = recheckBatchReadDao.listBatchRecheck(param);

        return recheckBatchReadDao.endPager(recheckBatchList);
    }


    public List<RecheckBatchDTO>  queryRecheckBatchs(String [] ids ,String areaCode){
        return recheckBatchReadDao.queryRecheckBatchs(ids,areaCode);
    }



    public RecheckBatchEntity getById(String id) {
         RecheckBatchDTO dto =  recheckBatchReadDao.getById(id);
        RecheckBatchEntity entity= new RecheckBatchEntity();
         BeanUtils.copyProperties(dto,entity);
         return entity;
    }

}
